From 99e774937b4d212dd2942064f713a30be41b8d1f Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 8 Apr 2015 17:08:21 +0100 Subject: [PATCH] libxenstat: always free qmp_stats Originally qmp_stats is only freed in failure path and leaked in success path. Instead of wiring up the success path, rearrange the code a bit to always free qmp_stats before checking if info is NULL. Signed-off-by: Wei Liu Cc: Ian Campbell Cc: Ian Jackson Cc: Charles Arnold Acked-by: Ian Jackson Acked-by: Ian Campbell --- tools/xenstat/libxenstat/src/xenstat_qmp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/xenstat/libxenstat/src/xenstat_qmp.c b/tools/xenstat/libxenstat/src/xenstat_qmp.c index aad15c8196..8d91feffa1 100644 --- a/tools/xenstat/libxenstat/src/xenstat_qmp.c +++ b/tools/xenstat/libxenstat/src/xenstat_qmp.c @@ -95,10 +95,10 @@ static char *qmp_get_block_image(xenstat_node *node, char *qmp_devname, int qfd) return NULL; /* Use libyajl version 2.0.3 or newer for the tree parser feature with bug fixes */ - if ((info = yajl_tree_parse((char *)qmp_stats, NULL, 0)) == NULL) { - free(qmp_stats); + info = yajl_tree_parse((char *)qmp_stats, NULL, 0); + free(qmp_stats); + if (info == NULL) return NULL; - } ptr[0] = qblock[QMP_BLOCK_RETURN]; /* "return" */ if ((ret_obj = yajl_tree_get(info, ptr, yajl_t_array)) == NULL) -- 2.30.2